var form = layui.form
var layer = layui.layer;
// 先获取用户**************
var id = new URLSearchParams(location.search).get('id')
console.log(id);
$.ajax({
    url: '/admin/users/'+ id,
    success: function (res) {
        console.log(res);
        layer.msg(res.message)
        form.val('user',res.data)
    }
})
// 点击立即提交 发送请求 跳转页面***********
$('#sub').on('submit', function (e) {
    e.preventDefault()
    // data.append('id', id)
    var data = $(this).serialize()
    // console.log(data);username=tom&nickname=hello&email=aaaa%40163.com&id=8
    $.ajax({
        url: '/admin/users',
        type: 'PUT',
        data:data,
        success: function (res) {
            console.log(res);
            layer.msg(res.message)
            if (res.status == 0) {
                location.href='./user.html'
            }
        }
   })


})
   